package com.yu.transfer;

import lombok.*;

import java.io.Serializable;

/**
 * @PackageName: com.yu.transfer
 * @Description:
 * @Version: v1.0.0
 * @Author: yuweilin
 * @Date: 11:27
 * <p>
 * Modification History:
 * Date         Author          Version            Description
 * ------------------------------------------------------------
 * 2021/2/5      yuweilin         v1.0.0               新建
 */
@AllArgsConstructor
@NoArgsConstructor
@Data
@Builder
public class RpcResponse<T> implements Serializable {
    private static final long serialVersionUID=715745410605631233L;
    private String requestId;
    private Integer code;
    private String message;
    private T data;

    public static <T> RpcResponse<T> success(T data,String requestId){
        RpcResponse<T> response = new RpcResponse<>();
        response.setCode(200);
        response.setMessage("远端调用成功");
        response.setRequestId(requestId);
        if (null!=data){
            response.setData(data);
        }
        return response;
    }

    public static <T> RpcResponse<T> fail(){
        RpcResponse<T> response = new RpcResponse<>();
        response.setCode(500);
        response.setMessage("远端调用失败");
        return response;
    }
}
